package com.health.ts.controller.sysmanage;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.health.ts.constant.ApiResult;
import com.health.ts.entity.sysmanage.SysMenu;
import com.health.ts.service.sysmanage.SysMenuService;
/**
 * 菜单管理
 * @author Administrator
 */
@Controller
@RequestMapping(value = "/api/menu")
public class MenuController {
	
	@Autowired
	SysMenuService sysMenuService;
	
	/**
	 * 新增或者修改菜单
	 * @param menu
	 * @return
	 */
	@RequestMapping(value="/addMenu", method=RequestMethod.POST)
	public ApiResult addMenu(@RequestBody SysMenu menu) {
		sysMenuService.saveOrUpdate(menu);
		return ApiResult.success();
	}
	
	/**
	 * 删除菜单
	 * @param id
	 * @return
	 */
	@RequestMapping(value="/{id}", method=RequestMethod.DELETE)
	public ApiResult deleteUser(@PathVariable String id) {
		sysMenuService.removeById(id);
		return ApiResult.success();
    }
	
	/**
	 * 查询菜单列表
	 * @param page
	 * @return
	 */
	@RequestMapping(value = "/listMenu",method=RequestMethod.POST)
	public ApiResult listMenu() {
		List<SysMenu> list = sysMenuService.list();
		return ApiResult.success(list);
	}

}
